package com.derbysoft.defender.api.response;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>some description here.</p>
 * Created by Afee Lee on 2017-03-26 14:28
 *
 * @author Afee Lee
 * @version 1.0
 * @see Object
 * @since 1.8
 */
public class OAuth2RefreshToken implements Serializable {
    private static final long serialVersionUID = 3449554332764129719L;

    private String value;

    private Date expiration;

    public OAuth2RefreshToken(String value) {
        this.value = value;
    }

    /**
     * Default constructor for JPA and other serialization tools.
     */
    @SuppressWarnings("unused")
    private OAuth2RefreshToken() {
        this(null);
    }

    public String getValue() {
        return value;
    }

    @Override
    public String toString() {
        return getValue();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof OAuth2RefreshToken)) {
            return false;
        }

        OAuth2RefreshToken that = (OAuth2RefreshToken) o;

        if (value != null ? !value.equals(that.value) : that.value != null) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        return value != null ? value.hashCode() : 0;
    }

    public OAuth2RefreshToken(String value, Date expiration) {
        this.value = value;
        this.expiration = expiration;
    }

    /**
     * The instant the token expires.
     *
     * @return The instant the token expires.
     */
    public Date getExpiration() {
        return expiration;
    }
}
